package com.keshihao.cmsservice.service.impl;

import com.keshihao.cmsservice.entity.CrmBanner;
import com.keshihao.cmsservice.mapper.CrmBannerMapper;
import com.keshihao.cmsservice.service.CrmBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author keshihao
 * @since 2020-06-15
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {

  // 查询所有banner
  @Cacheable(value = "banner",key = "'selectIndexList'")
  @Override
  public List<CrmBanner> selectAllBanner() {
    return baseMapper.selectList(null);
  }

  @CacheEvict(value = "banner", allEntries=true)
  @Override
  public void saveBanner(CrmBanner banner) {
    baseMapper.insert(banner);
  }

  @CacheEvict(value = "banner", allEntries=true)
  @Override
  public void updateBannerById(CrmBanner banner) {
    baseMapper.updateById(banner);
  }

  @CacheEvict(value = "banner", allEntries=true)
  @Override
  public void removeBannerById(String id) {
    baseMapper.deleteById(id);
  }

}
